package other.nowcoder.easy;

import java.util.Scanner;

/**
 * @author bruin_du
 * @description 完全数计算
 * https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84?
 * tpId=37&&tqId=21279&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 * @date 2022/5/16 11:37
 **/
public class CountPerfectNumber {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int count = 0;
            for(int i = 6 ; i <= n ; i++) {
                if(perfectNum(i))
                    count++;
            }
            System.out.println(count);
        }
    }
    public static boolean perfectNum(int num){
        int sqrt = (int)Math.sqrt(num);
        int sum = 0;
        for(int i = 1 ; i <= sqrt ; i++){
            if(num % i == 0){
                sum += i;
                int tmp = num / i;
                if(num != tmp && tmp != i)
                    sum += tmp;
            }
        }
        return(sum == num);
    }
}
